<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>北京联合大学</title>
</head>
<!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://at.alicdn.com/t/font_835526_xufba1hg66.css">
<link rel="stylesheet" href="../../css/Initialization.css">
<link rel="stylesheet" href="../../css/commen.css">
<link rel="stylesheet" href="../../css/contribution.css">
<body>
<div id="content">
    <div class="initer">
            <!-- 具体内容 -->
            <!-- 单元知识点 具体内容 -->
            <div class="bread">
                <div class="plain" th:text="${menu.menuname}">成立公司</div>
                <div class="plain">
                    <i class="iconfont icon-right"></i>
                </div>
                <div class="plain current" th:text="${smenu.menuname}">单元知识点</div>
            </div>
            <div class="teamdesc" th:if="${content != null}" th:utext="${content.detail}"></div>
            <div class="teamcontent">
                <div class="students" th:if="${person.isjoin != 0}">
                    <input type="hidden" id="mid" name="mid" th:value="${menu.id}"/>
                    <input type="hidden" id="sid" name="sid" th:value="${smenu.id}"/>
                    <div class="student" th:each="item : ${personList}">
                        <span><i class="iconfont icon-wo"></i></span>
                        <input type="hidden" id="personid" name="personid" th:value="${item.id}"/>
                        <input type="hidden" id="groupid" name="groupid" th:value="${item.groupid}"/>
                        <span class="name" th:text="${item.realname}">张三</span>
                        <span class="class">同学</span>
                        <span class="select">
                                <div class="myselect">
                                    <span class="value" id="evaluation" name="evaluation" th:text="${item.score}">请选择</span>
                                    <ul class="selectvalue none">
                                        <li>1</li>
                                        <li>2</li>
                                        <li>3</li>
                                        <li>4</li>
                                        <li>5</li>
                                        <li>6</li>
                                        <li>7</li>
                                        <li>8</li>
                                        <li>9</li>
                                        <li>10</li>
                                    </ul>
                                </div>
                            </span>
                    </div>
                    <div class="submitbutton">
                        <div class="max-button submit" id="subBut">
                            提交
                        </div>
                    </div>
                </div>
            </div>
            <div class="must" th:if="${person.isjoin != 0}">
                * 单元互评说明文字 及要求每个学生相互打分，不能有同样的分值，只提交一次 不允许修改
            </div>
            <div class="must" th:if="${person.isjoin == 0}">
                * 你还没有加入任何小组，请先加入小组并完成相关作业
            </div>
        </div>
</div>
<script src="../../js/jquery-3.4.1.min.js"></script>
<script src="../../js/bootstrap.min.js"></script>
<script src="../../js/commen.js"></script>
<script>
    $(function(){
        $("#subBut").click(function(){
            var str = "";
            var groupid = 0;
            var mid = $("#mid").val();
            var sid = $("#sid").val();
            var $arr = Array.from($('.myselect .value'));
            var resultarr = [];
            for(var i=0;i<$arr.length;i++){
                resultarr.push($arr[i].innerHTML);
            }
            var resarr = Array.from(new Set(resultarr));
            if(resarr.length == resultarr.length){
                $(".student").each(function () {
                    groupid = $(this).find("#groupid").val();
                    str += groupid + "-" + $(this).find("#personid").val() + "-" + $(this).find(".name").html() + "-" + $(this).find("#evaluation").html() + ",";
                });
                $.ajax({
                    type : "POST",
                    url : "addEvaluation",
                    data : {mid,sid,evaluation: str.substring(0,str.length-1),groupid: groupid},
                    dataType : "json",
                    success : function(json) {
                        if(json.state == error){
                            alert(json.result);
                        }else{
                            alert(json.result);
                            //location.href = "basicslist?mid="+mid+"&sid="+sid;
                        }
                    },
                    error:function(msg){
                        alert("程序出错，请联系管理员");
                    }
                });
            }else{
                alert('不允许有相同分值，请调整分值后提交。！')
                return
            }
        });
    });
</script>
</body>
</html>

